﻿<%@ WebHandler Language="C#" Class="Upload" %>

using System;
using System.Web;

public class Upload : IHttpHandler, System.Web.SessionState.IRequiresSessionState {
    
    public void ProcessRequest (HttpContext context) {
        try
        {
            HttpPostedFile file = context.Request.Files["fileData"];
            //string tmp = HttpContext.Current.Server.MapPath("/"+context.Request["folder"].ToString());
            //System.IO.File.Copy(tmp + "/bochka_vang_co_dien.jpg", tmp + "/bochka_vang_co_dien_copy.jpg");
            file.SaveAs(System.IO.Path.Combine(context.Request.MapPath(context.Request["folder"]), file.FileName));
            
            context.Response.Write("1");
        }
        catch
        {
            context.Response.Write("0");
        }

    }
 
    public bool IsReusable {
        get {
            return false;
        }
    }

}